/**
 * 列表视图
 */
Ext.define('cc.self.view.SelfBusGridView', {
	extend: 'Ext.grid.Panel',
	uses: ['cc.self.store.SelfBus'],
	
	cls: 'c-grid-header',
	
	initComponent: function(){
		var me = this;
		
		if(!me.store){
			me.store = Ext.create('cc.self.store.SelfBus');
		}
		me.store.load();
		if(!me.columns){
			me.columns = [{
				text: '编号',
				dataIndex: 'code'
			}, {
				text: '状态',
				dataIndex: 'status',
				renderer: function(v) {
					var s = '不可结算';
					if(v == 0) {
						s = '不完整';
					}else if(v == 1) {
						s = '可结算';
					}else if(v == 2) {
						s = '已结算';
					}
					return Ext.String.format('<div class="cc_state s{0}">{1}</div>', v, s);
				}
			},{
				text: '外销发票号',
				dataIndex: 'wx_no'
			}, {
				text: '公司发票号',
				dataIndex: 'gs_no'
			}, {
				text: '客户名称',
				dataIndex: 'customer'
			}, {
				xtype:'datecolumn',
				format: 'Y-m-d',
				text: '报关日期',
				dataIndex: 'bg_date'
			}, {
				text: '报关单号',
				dataIndex: 'bg_no'
			}, {
				text: '报关金额',
				dataIndex: 'bg_money'
			}, {
				text: '启运港',
				dataIndex: 'port_from'
			}, {
				text: '目的港',
				dataIndex: 'port_to'
			}, {
				xtype:'datecolumn',
				format: 'Y-m-d',
				text: '退税申报日期',
				dataIndex: 'ts_date'
			}, {
				text: '贸易方式',
				dataIndex: 'bus_way'
			}, {
				text: '收汇方式',
				dataIndex: 'get_way'
			}, {
				header: '内运费',
				columns: [{
					text: '开票单位',
					dataIndex: 'ny_org'
				}, {
					xtype:'datecolumn',
					format: 'Y-m-d',
					text: '发票日期',
					dataIndex: 'ny_date'
				}, {
					text: '内运费',
					dataIndex: 'ny_money'
				}]
			}, {
				header: '相关杂费',
				columns: [{
					text: '开票单位',
					dataIndex: 'zf_org'
				}, {
					xtype:'datecolumn',
					format: 'Y-m-d',
					text: '发票日期',
					dataIndex: 'zf_date'
				}, {
					text: '相关杂费',
					dataIndex: 'zf_money'
				}]
			},{
				header: '单证费',
				columns: [{
					text: '开票单位',
					dataIndex: 'dz_org'
				}, {
					xtype:'datecolumn',
					format: 'Y-m-d',
					text: '发票日期',
					dataIndex: 'dz_date'
				}, {
					text: '单证费',
					dataIndex: 'dz_money'
				}]
			},{
				header: '快件费',
				columns: [{
					text: '开票单位',
					dataIndex: 'kj_org'
				}, {
					xtype:'datecolumn',
					format: 'Y-m-d',
					text: '发票日期',
					dataIndex: 'kj_date'
				}, {
					text: '快件费',
					dataIndex: 'kj_money'
				}]
			},{
				header: '代理费',
				columns: [{
					text: '开票单位',
					dataIndex: 'dl_org'
				}, {
					xtype:'datecolumn',
					format: 'Y-m-d',
					text: '发票日期',
					dataIndex: 'dl_date'
				}, {
					text: '代理费',
					dataIndex: 'dl_money'
				}]
			}, {
				text: '结汇收入',
				dataIndex: 'jh_money'
			}, {
				text: '工厂货款',
				dataIndex: 'cg_money'
			}, {
				text: '退税收入',
				dataIndex: 'ts_money'
			}, {
				text: '其他费用',
				dataIndex: 'other_money'
			}, {
				text: '已付货款',
				dataIndex: 'payed_money'
			}, {
				text: '可付货款',
				dataIndex: 'paying_money'
			}, {
				text: '业务利润',
				dataIndex: 'bus_profit'
			}, {
				text: '业务员提成',
				dataIndex: 'ywy_money'
			}, {
				text: '备注',
				dataIndex: 'remark'
			}, {
				text: '业务员',
				dataIndex: 'ywy'
			}, {
				xtype:'datecolumn',
				format: 'Y-m-d',
				text: '业务员日期',
				dataIndex: 'ywy_date'
			}, {
				text: '制单人',
				dataIndex: 'zdr'
			}, {
				xtype:'datecolumn',
				format: 'Y-m-d',
				text: '制单日期',
				dataIndex: 'zd_date'
			}, {
				text: '审核人',
				dataIndex: 'shr'
			}, {
				xtype:'datecolumn',
				format: 'Y-m-d',
				text: '审核日期',
				dataIndex: 'sh_date'
			}, {
				text: '存档人',
				dataIndex: 'cdr'
			}, {
				xtype:'datecolumn',
				format: 'Y-m-d',
				text: '存档日期',
				dataIndex: 'cd_date'
			}];
		}
		me.dockedItems = [{
	        xtype: 'pagingtoolbar',
	        store: me.store,   // same store GridPanel is using
	        dock: 'bottom',
	        displayInfo: true
	    }];
		
		me.callParent(arguments);
	}
});
